Skip to content

feat: refactor serializers & code cleanup#661

Merged
cofin merged 6 commits intomainfrom
chore/fixes-cleanup
Feb 1, 2026
Merged

feat: refactor serializers & code cleanup#661
cofin merged 6 commits intomainfrom
chore/fixes-cleanup

Conversation

@cofin
Copy link
Member

@cofin cofin commented Jan 23, 2026

Summary

  • non-breaking code cleanup/organization in the repository layer.
  • Improved serialization and removed duplication between cache handler and normal serializers
  • Bug Fixes

Detailed Changes

Repository & Caching Refactor

  • Reduced Bloat: Moved internal caching helpers (_normalize_cache_key_value, _build_list_cache_key, etc.) out of advanced_alchemy/repository/_async.py and into advanced_alchemy/repository/_util.py.
  • Unified Serialization:
    • Refactored advanced_alchemy/_serialization.py to expose encode_complex_type and decode_complex_type.
    • Updated advanced_alchemy/cache/serializers.py and repository/_util.py to share this logic, removing duplicate handling for types like UUID, datetime, and Decimal.
  • Cleanup: Removed unused imports (dataclasses, hashlib, etc.) from the repository files.

Bug Fixes

- Introduced `encode_complex_type` and `decode_complex_type` functions to handle serialization and deserialization of complex types (datetime, date, time, timedelta, Decimal, bytes, UUID, set).
- Removed legacy JSON encoder/decoder functions from `serializers.py` and replaced their usage with the new functions.
- Updated tests to validate the new serialization logic for various complex types.
- Added error handling for unsupported types during encoding.
- Enhanced import handling for optional dependencies in Alembic scripts.
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 92.24806% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.04%. Comparing base (658d417) to head (d819f47).

Files with missing lines Patch % Lines
advanced_alchemy/repository/_util.py 88.40% 4 Missing and 4 partials ⚠️
advanced_alchemy/_serialization.py 96.22% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #661      +/-   ##
==========================================
+ Coverage   79.08%   80.04%   +0.95%     
==========================================
  Files          99       99              
  Lines        7922     7836      -86     
  Branches     1073     1050      -23     
==========================================
+ Hits         6265     6272       +7     
+ Misses       1316     1233      -83     
+ Partials      341      331      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cofin and others added 2 commits February 1, 2026 09:12
Signed-off-by: Cody Fincher <204685+cofin@users.noreply.github.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 1, 2026

@cofin cofin merged commit b16605d into main Feb 1, 2026
21 checks passed
@cofin cofin deleted the chore/fixes-cleanup branch February 1, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Core dependencies not installed by default Bug: SQLAlchemy's StatementError (or OperationalError) is incorrectly wrapped as IntegrityError

3 participants